from django.shortcuts import render
from device.models import Device, MaintenanceRecord
from device.serializers import (
    DeviceSerializer, DeviceCreateUpdateSerializer,
    MaintenanceRecordSerializer, MaintenanceRecordCreateUpdateSerializer
)
from dvadmin.utils.viewset import CustomModelViewSet

# Create your views here.

class DeviceModelViewSet(CustomModelViewSet):
    """
    设备管理接口
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = Device.objects.all()
    serializer_class = DeviceSerializer
    create_serializer_class = DeviceCreateUpdateSerializer
    update_serializer_class = DeviceCreateUpdateSerializer

class MaintenanceRecordModelViewSet(CustomModelViewSet):
    """
    维护记录接口
    list:查询
    create:新增
    update:修改
    retrieve:单例
    destroy:删除
    """
    queryset = MaintenanceRecord.objects.all()
    serializer_class = MaintenanceRecordSerializer
    create_serializer_class = MaintenanceRecordCreateUpdateSerializer
    update_serializer_class = MaintenanceRecordCreateUpdateSerializer
